﻿using CPPEI.Coolzon.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace CPPEI.BD.RemoteLauncher
{
    [XConfigRoot("Environment")]
    public class Environment
    {
        private static Version _version;
        /// <summary>
        /// 获得主程序的版本号
        /// </summary>
        public static Version Version
        {
            get
            {
                if (_version == null)
                {
                    _version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
                }
                return _version;
            }
        }

        /// <summary>
        /// 版本信息-.-.-
        /// </summary>
        public static string Version3
        {
            get
            {
                return Version.ToString(3);
            }
        }

        /// <summary>
        /// 版本信息-.-.-.-
        /// </summary>
        public static string Version4
        {
            get
            {
                return Version.ToString(4);
            }
        }


        private static Environment s_instance;
        public static Environment Instance
        {
            get
            {
                if (s_instance == null)
                {
                    s_instance = new Environment();
                }
                return s_instance;
            }
        }

        /// <summary>
        /// 目标计算机ip
        /// </summary>
        [XConfig("TargetIP")]
        public string TargetIP { get; set; }

        [XConfig("Port")]
        public int Port { get; set; }


        /// <summary>
        /// 获取Environment.xml文件的地址
        /// </summary>
        /// <returns></returns>
        public static string GetEnvironmentFilePath()
        {
            return string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "Config\\Environment.xml"); ;
        }
    }
}
